package com.l024.android_ljl.entity;


import android.text.TextUtils;

import com.l024.android_ljl.util.RegexUtils;
import com.quantstack.llcommonlibrary.base.BaseHttpResult;

import java.io.Serializable;

/**
 * 系统用户
 */
public class SysUserEntity extends BaseHttpResult<SysUserEntity> implements Serializable {
    public long id;
    public String name;
    //接受但是不序列化
    public String password;
    public String avator;
    public String phone;
    public int sex = 1;
    public long createTime;
    public String token;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAvator() {
        return avator;
    }

    public void setAvator(String avator) {
        this.avator = avator;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    @Override
    public String toString() {
        return "SysUserEntity{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", avator='" + avator + '\'' +
                ", phone='" + phone + '\'' +
                ", sex=" + sex +
                ", createTime=" + createTime +
                ", token='" + token + '\'' +
                '}';
    }

    public String check(){
        if(TextUtils.isEmpty(this.name)){
            return "请输入姓名";
        }
        if(this.name.length()<2||this.name.length()>10){
            return "姓名长度应该在2-10之间";
        }
        if(TextUtils.isEmpty(this.phone)){
            return "请输入手机号";
        }
        if(!RegexUtils.isPhone(this.phone)){
            return "请输入正确的手机号";
        }
        if(TextUtils.isEmpty(this.password)){
            return "请输入密码";
        }
        if(this.password.length()<6||this.password.length()>20){
            return "密码长度应该在6-20之间";
        }
        return "";
    }
}
